package com.anjiplus.template.gaea.business.work.point.dao;

import com.anjiplus.template.gaea.business.work.point.entity.Point;
import com.anjiplus.template.gaea.business.work.station.entity.Station;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author yxm
 */
@Mapper
public interface PointDao {

    /**
     * 查询全部参数点列表
     *
     * @return
     */
    @Select("select * from t_point where deleted = 0")
    List<Point> listAll();

    /**
     * 查询指定站点和参数点名称的参数点列表
     *
     * @param id 站点id
     * @param name 参数点name
     * @return
     */
    @Select("select * from t_point where stationId = #{id} and name like concat('%', #{name}, '%') and deleted = 0")
    List<Point> listByStationIdAndPointName(String id, String name);

    /**
     * 查询指定站点的参数点列表
     *
     * @param id 站点id
     * @return
     */
    @Select("select * from t_point where stationId = #{id} and deleted = 0")
    List<Point> listByStationId(String id);

    /**
     * 根据参数点名称模糊查询参数点列表
     *
     * @param name
     * @return
     */
    @Select("select * from t_point where name like concat('%', #{name}, '%') and deleted = 0")
    List<Point> listByPointName(String name);

    /**
     * 添加参数点
     *
     * @param point
     * @return
     */
    @Insert("insert into t_point(id,code,name,unit,stationId,deleted) values(uuid(),#{code},#{name},#{unit},#{stationId},0)")
    int add(Point point);

    /**
     * 移除参数点
     * @param id
     * @return
     */
    @Delete("update t_point set deleted=1 where id=#{id}")
    int remove(String id);

    /**
     * 修改参数点
     *
     * @param point
     * @return
     */
    @Update("update t_point set name=#{name},code=#{code},unit=#{unit},stationId=#{stationId} where id=#{id}")
    int update(Point point);

}
